<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>安装HaSog幻神商城系统</title>
    <meta name="renderer" content="webkit">
    <link rel="icon" href="/favicon.png">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/lib/layui-v2.5.6/css/layui.css?v=<?php echo time() ?>" media="all">
    <link rel="stylesheet" href="/static/common/css/insatll.css?v=<?php echo time() ?>" media="all">
    <style type="text/css">
small{
    float: left;
    margin: 10px 0px;
    font-size: 14px;
    color: #f00;

}
    </style>
</head>
<body>
<h1><img src="/static/images/hasog.png"></h1>
<h2>安装HaSog幻神商城系统</h2>
<div class="content">
    <p class="desc">
        使用过程中遇到任何问题可联系
        <a href="https://www.hasog.com?f=hasoginstall"  target="_blank">幻神科技官网</a>
    </p>

    <form class="layui-form layui-form-pane" action="">

        <?php if ($errorInfo): ?>
            <div class="error">
                <?php echo $errorInfo;  ?>
            </div>
        <?php endif; ?>

    <p class="desc">
        安装版本
    </p>
        <div class="bg">
            <table class="layui-table">
                <colgroup>
                    <col width="180">
                    <col>
                </colgroup>
                <tbody>
                <tr>
                    <td>HaSog 版本</td>
                    <td>v{$hasog.version}</td>
                </tr>
                <tr>
                    <td>发布日期</td>
                    <td>{$hasog.release}</td>
                </tr>
                <tr>
                    <td>软件下载</td>
                    <td>
                        <a href="https://gitee.com/orzice/hasog" target="_blank">码云</a>
                        /
                       <a href="https://github.com/orzice/hasog" target="_blank">Github</a>
                       
                    </td>
                </tr>
                <tr>
                    <td>技术支持</td>
                    <td>
                    <a href="https://www.hasog.com" target="_blank">河南幻神科技</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

        <?php if ($errorInfo): ?>
           <?php echo'</form></div></body></html>';exit; ?>
        <?php endif; ?>


    <p class="desc">
        数据库配置
    </p>
        <div class="bg">
            <div class="layui-form-item">
                <label class="layui-form-label">数据库地址</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="hostname" autocomplete="off" lay-verify="required" lay-reqtext="请输入数据库地址" placeholder="请输入数据库地址" value="localhost">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">数据库端口</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="hostport" autocomplete="off" lay-verify="required" lay-reqtext="请输入数据库端口" placeholder="请输入数据库端口" value="3306">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">数据库名称</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="database" autocomplete="off" lay-verify="required" lay-reqtext="请输入数据库名称" placeholder="请输入数据库名称" value="hasog">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">数据表前缀</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="prefix" autocomplete="off" lay-verify="required" lay-reqtext="请输入数据表前缀" placeholder="请输入数据表前缀" value="hs_">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">数据库账号</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="db_username" autocomplete="off" lay-verify="required" lay-reqtext="请输入数据库账号" placeholder="请输入数据库账号" value="root">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">数据库密码</label>
                <div class="layui-input-block">
                    <input type="password" class="layui-input" name="db_password" autocomplete="off" lay-verify="required" lay-reqtext="请输入数据库密码" placeholder="请输入数据库密码">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">覆盖数据库</label>
                <div class="layui-input-block" style="text-align: left">
                    <input type="radio" name="cover" value="1" title="覆盖">
                    <input type="radio" name="cover" value="0" title="不覆盖" checked>
                </div>
            </div>
        </div>

    <p class="desc">
        云平台配置
    </p>
        <div class="bg">

            <div class="layui-form-item">
                <label class="layui-form-label">站点唯一ID</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="uniqueid" autocomplete="off" lay-verify="required" lay-reqtext="请输入站点唯一ID" placeholder="请输入站点唯一ID" value="{:getuniqueid()}">
                    <small>注意！此配置为站点唯一ID，供云平台使用！请牢记！</small>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务器IP</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="ServerIp" autocomplete="off" lay-verify="required" lay-reqtext="请输入服务器IP" placeholder="请输入服务器IP" value="{:getServerIp()}">
                    <small>注意！请核对是否为服务器公网IP！</small>
                </div>
            </div>

        </div>

    <p class="desc">
        加密配置
    </p>
        <div class="bg">


            <div class="layui-form-item">
                <label class="layui-form-label">后台加密</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="key" autocomplete="off" lay-verify="required" lay-reqtext="请输入加密key" placeholder="请输入加密key" value="{:getpwSDK()}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">用户加密</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="key_user" autocomplete="off" lay-verify="required" lay-reqtext="请输入加密key" placeholder="请输入加密key" value="{:getuserPW()}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">后台的地址</label>
                <div class="layui-input-block">
                    <input class="layui-input" id="key_admin" name="key_admin" autocomplete="off" lay-verify="required" lay-reqtext="请输入后台名称" placeholder="请输入后台名称" value="{:getAdmin()}">
                </div>
            </div>
            <p class="desc" style="color: #ff0000;">
                加密是给登录密码进行加密！安装后不要修改并牢记！否则所有用户无法登陆！
            </p>
        </div>

    <p class="desc">
        后台配置
    </p>
        <div class="bg">

            <div class="layui-form-item">
                <label class="layui-form-label">管理员账号</label>
                <div class="layui-input-block">
                    <input class="layui-input" name="username" autocomplete="off" lay-verify="required" lay-reqtext="请输入管理员账号" placeholder="请输入管理员账号" value="admin">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">管理员密码</label>
                <div class="layui-input-block">
                    <input type="password" class="layui-input" name="password" autocomplete="off" lay-verify="required" lay-reqtext="请输入管理员密码" placeholder="请输入管理员密码">
                </div>
            </div>

            <p class="desc">
                后台登录地址： <a id="admin_url" href="<?php echo $currentHost; ?>admin" target="_blank"><?php echo $currentHost; ?><span id="admin_name">admin</a></span>
            </p>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn layui-btn-normal <?php echo $errorInfo ? 'layui-btn-disabled' : '' ?>" lay-submit="" lay-filter="install">确定安装</button>
        </div>
    </form>
</div>
<script src="/static/lib/layui-v2.5.6/layui.js?v=<?php echo time() ?>" charset="utf-8"></script>
<script>

    layui.use(['form', 'layer'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

        var val = $('#key_admin').val();
        $("#admin_url").attr('href','<?php echo $currentHost; ?>'+val);
        $("#admin_name").text(val);
            
        $("#key_admin").bind("input propertychange", function () {
            var val = $(this).val();
            $("#admin_url").attr('href','<?php echo $currentHost; ?>'+val);
            $("#admin_name").text(val);
        });

        form.on('submit(install)', function (data) {
            if ($(this).hasClass('layui-btn-disabled')) {
                return false;
            }
            var _data = data.field;
            var loading = layer.msg('正在安装...', {
                icon: 16,
                shade: 0.2,
                time: false
            });
            $.ajax({
                url: window.location.href,
                type: 'post',
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                dataType: "json",
                data: _data,
                timeout: 60000,
                success: function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {icon: 1}, function () {
                            window.location.href = location.protocol + '//' + location.host + '/' + data.url;
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2});
                    }
                },
                error: function (xhr, textstatus, thrown) {
                    layer.close(loading);
                    layer.msg('Status:' + xhr.status + '，' + xhr.statusText + '，请稍后再试！', {icon: 2});
                    return false;
                }
            });
            return false;
        });
    });
</script>
</body>
</html>